Add Method (Attachments Collection) 

The Add method creates a new Attachment object in the Attachments collection.

Syntax

Set objAttachment = objAttachColl.Add( [ name, position, type, source ] )

Parameters

objAttachment

On successful return, contains the new Attachment object.

objAttachColl

Required. The Attachments collection object.

name

Optional. String. The display name of the attachment. The default value is an empty string. To allow a user to click on the attachment that appears in the message and activate an associated application, supply the full filename, including the file extension.

position

Optional. Long. The position of the attachment within the body text of the message. The default value is 0.

type

Optional. Long. The type of attachment; either mapiFileData, mapiFileLink, mapiOLE, or mapiEmbeddedMessage. The default value is mapiFileData.

source

Optional. String. The path and filename of the file containing the data for the attachment, or the unique identifier of the message to be embedded. The path and filename must be in the appropriate format for the attachment type, specified by the type parameter. The default value is an empty string.

 

Remarks

The Add method parameters correspond to the Name11THH7G, Position2F4KWK5, TypeENNF7U, and SourceT1L9WE properties of the Attachment35G2KD object. The source parameter is also closely related to the ReadFromFile7TMO9S method s filename parameter.

You can supply the data for the attachment at the same time that you add the attachment to the collection. The Add method operates differently, depending on the value of the type parameter. The following table describes its operation.

Value of type parameter

Value of source parameter

mapiFileData

Specifies a full path and filename that contains the data for the attachment, for example C:\DOCUMENT\BUDGET.XLS. The data is read into the attachment.

mapiFileLink

Specifies a full path and filename in a universal naming convention (UNC) format, such as \\SALES\INFO\PRODUCTS\NEWS.DOC. The attachment is a link, so the Add method does not read the data.

mapiOLE

Specifies a full path and filename to a valid OLE docfile, for example C:\DOCUMENT\BUDGET2.XLS. The data is read into the attachment.

mapiEmbeddedMessage

Specifies the ID1RMKEX8 property of the message to be embedded. The message is read into the attachment.

 

When the type parameter has the value mapiFileLink, the source parameter is a full path and filename in a UNC format. This is suitable for sending attachments to recipients who have access to a common file server. Note that when you use the type mapiFileLink, the OLE Messaging Library does not validate the filename.

If you do not specify the type and source parameters when you call the Add method, you must later explicitly set these properties. For mapiFileData and mapiOLE types, you must also call the ReadFromFile7TMO9S method on the new Attachment35G2KD object to load the attachment s content.

The Index5RHX73 property of the new Attachment object equals the new CountBE13RG property of the Attachments collection.

The attachment is saved in the MAPI system when you Update2E9FDDD or Send1JTD0I1 the parent MessageC062VO object.